package net.modul.dept.action;

import java.util.ArrayList;
import java.util.List;

import net.common.action.GeneralAction;
import net.modul.dept.service.EmployeeDeleteService;
import net.modul.dept.service.EmployeeEditorService;
import net.modul.dept.service.EmployeeFindService;
import net.modul.dept.service.EmployeeSearchService;
import net.modul.dept.vo.EmployeeVo;

public class EmployeeAction extends GeneralAction {

	private static final long serialVersionUID = 7127573666355745443L;

	private EmployeeVo bean = new EmployeeVo();
	private List<EmployeeVo> list = new ArrayList<EmployeeVo>();
	
	public String search() throws Exception {
		EmployeeSearchService service = new EmployeeSearchService();
		service.setBean(bean);
		service.setPageBean(pageBean);
		service.invoke();
		list = service.getList();
		return SUCCESS;
	}
	
	public String editor() throws Exception {
		EmployeeEditorService service = new EmployeeEditorService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}
	
	public String find() throws Exception {
		if(bean.getEmpl_id() != null) {			
			EmployeeFindService service = new EmployeeFindService();
			service.setId(bean.getEmpl_id());
			service.invoke();
			bean = service.getBean();
		}
		return SUCCESS;
	}
	
	public String delete() throws Exception {
		EmployeeDeleteService service = new EmployeeDeleteService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}
	
	public EmployeeVo getBean() {
		return bean;
	}
	public void setBean(EmployeeVo bean) {
		this.bean = bean;
	}
	public List<EmployeeVo> getList() {
		return list;
	}
	public void setList(List<EmployeeVo> list) {
		this.list = list;
	}
}
